package com.app.networkmonitor;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.zndroid.netmonitor.NetworkMonitor;
import com.zndroid.netmonitor.monitor.INetChangeCallBack;
import com.zndroid.netmonitor.monitor.INetSpeedChangeCallBack;

public class MainActivity extends AppCompatActivity {
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.tv_show);
    }

    public void stat(View view) {
//        NetworkMonitor.getInstance().startMonitor(this, new INetChangeCallBack() {
//            @Override
//            public void onNetChanged(boolean isConnect, String type, int signal) {
////                Log.i("hyhy", "dddd =" + isConnect + " " + type + " " + signal);
//            }
//
//            @Override
//            public void onNetConnected(boolean isConnect, String type) {
//                Log.i("hyhy", isConnect + " " + type);
//            }
//        });

        NetworkMonitor.getInstance().startSpeedMonitor(this, new INetSpeedChangeCallBack() {
            @Override
            public void onNetSpeedChanged(double speed, String formatSpeed) {
                Log.i("hyhy", speed + " " + formatSpeed);
                textView.setText(formatSpeed);
            }
        });
    }

    public void stop(View view) {
//        NetworkMonitor.getInstance().stopMonitor();
        NetworkMonitor.getInstance().stopSpeedMonitor(this);
    }
}